package com.echo.yixiaowu.feature.main

import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionScope
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.echo.yixiaowu.feature.main.home.HomePage
import com.echo.yixiaowu.feature.main.home.bottom.MainBottomBar
import com.echo.yixiaowu.main.MinePage
import com.echo.yixiaowu.main.page.Message.MessagePage
import com.echo.yixiaowu.main.page.following.FollowingPage
import com.echo.yixiaowu.route.AppRoute
import com.echo.yixiaowu.util.NavigationHelper

@OptIn(ExperimentalSharedTransitionApi::class)
@Composable
fun MainTabsScreen(
    navController: NavHostController,
    sharedTransitionScope: SharedTransitionScope,
    animatedVisibilityScope: AnimatedVisibilityScope,
    navigationHelper: NavigationHelper
) {
    val tabsNavController = rememberNavController()

    Scaffold(bottomBar = {
        MainBottomBar(navController = tabsNavController)
    }) { paddingValues ->
        NavHost(
            navController = tabsNavController,
            startDestination = AppRoute.Home,
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            popEnterTransition = { EnterTransition.None },
            popExitTransition = { ExitTransition.None }
        ) {
            composable<AppRoute.Home> {
                HomePage(
                    sharedTransitionScope = sharedTransitionScope,
                    animatedVisibilityScope = animatedVisibilityScope
                ) {
                    navigationHelper.navigateTo(it)
                }
            }

            composable<AppRoute.Follow> {
                FollowingPage(
                    modifier = Modifier.padding(paddingValues),
                ) {
                    navigationHelper.navigateTo(it)
                }
            }

            composable<AppRoute.Message> {
                MessagePage(modifier = Modifier.padding(paddingValues))
            }

            composable<AppRoute.Mine> {
                MinePage(modifier = Modifier.padding(paddingValues))
            }
        }
    }
}
